/**********************************************************************************************/
/* FBL_Algs_Database.h																		  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006                                        					  */
/* All Rights Reserved.                                                 					  */
/**********************************************************************************************/

#ifndef _FBL_Algs_Database_h
   #define _FBL_Algs_Database_h
#pragma once

#include <VShared/FBL/publ/Interfaces/FBL_I_Database.h>
#include <VShared/FBL/publ/Interfaces/FBL_I_Table.h>
#include <VShared/FBL/publ/Interfaces/FBL_I_Link.h>

// FINAL:
#include <VShared/FBL/publ/Headers/FBL_pre_header.h>


/**********************************************************************************************/
FBL_Begin_Namespace


/**********************************************************************************************/
// Methods to access the array of databases.
// You can get a database by its index or name.
// In the case of wrong index or name it returns NULL pointer.
//
FBL_EXP I_Database_Ptr get_Database( ulong inIndex ) throw();
FBL_EXP I_Database_Ptr get_Database( const UChar* inName ) throw();


/**********************************************************************************************/
// Returns the current version of database format.
//
FBL_EXP ushort 	GetCurrentVersion( void );


/**********************************************************************************************/
// The following methods work on a closed database:

/// Returns the version of format of database file.
/// inLocation should point the Description Volume (.vdb) of database.
/// Returns 0 in case of not recognized Valentina format.
FBL_EXP ulong GetDatabaseVersion( I_Location_Ptr inLocation );

// Returns the schema version from custom header of  database file.
// inLocation should point the Description Volume (.vdb) of database.
FBL_EXP ushort GetSchemaVersion( I_Location_Ptr inLocation );

// Returns the database mode from custom header of  database file.
// inLocation should point the Description Volume (.vdb) of database.
FBL_EXP DbMode GetDatabaseMode( I_Location_Ptr inLocation );

// Returns true if database encrypted from custom header of database file.
// inLocation should point the Description Volume (.vdb) of database.
FBL_EXP bool GetIsStructureEncrypted( I_Location_Ptr inLocation );


/**********************************************************************************************/
// Convert first-version database to the second one.
// if inSegmentSize == 0 then use segment size from 1.x database.
//
FBL_EXP void ConvertDB_1_2( 
	I_Location_Ptr 		in1Location,
	I_Location_Ptr 		in2Location,
	bool				inDataLoad = true,
	const char*			inDb1Key = NULL,
	const char*			inStructureDb1Key = NULL,
	ulong				inSegmentSize = 0 );


/**********************************************************************************************/
FBL_End_Namespace

#include <VShared/FBL/publ/Headers/FBL_post_header.h>

#endif // _FBL_Algs_Database_h
